<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API帮助文档</title>

    <link rel="stylesheet" href="./js/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="./js/bootstrap-icons/font/bootstrap-icons.css">
    <link rel="stylesheet" href="./css/index.css">
    <link rel="stylesheet" href="./css/API.css">
</head>

<body>
    <nav class="navbar navbar-expand-lg navbar-dark fixed-top">
        <div class="container">
            <a class="navbar-brand" href="index.html">四川测绘 · DTS</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="index.html">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="task">任务中心</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="user">用户中心</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="clientDown.html">下载中心</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="monitor">监控中心</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">帮助文档</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="breadcrumb-area">
        <div class="top-breadcrumb-area bg-img bg-overlay d-flex align-items-center justify-content-center"
            style="background-image: url(./assets/img/bg-img/1.jpg);">
            <h2>帮助文档&nbsp;</h2>
        </div>
        <div class="overlay"></div>

        <div class="container">
            <div class="row">
                <div class="col-12">
                    <nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html"><i class="bi-house-door"></i> 首页</a></li>
                            <li class="breadcrumb-item active" aria-current="page">帮助文档</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-2 leftNavbar">
                <div id="list-example" class="list-group">
                    <a class="list-group-item list-group-item-action" href="#list-item-1">API 服务简介</a>
                    <a class="list-group-item list-group-item-action" href="#list-item-2">API 接口说明</a>
                    <a class="list-group-item list-group-item-action" href="#list-item-3">使用示例</a>
                    <!-- <div class="list-group-item list-group-item-action" href="#list-item-3">
                        <h2 class="accordion-header" id="headingOne">
                            <button class="" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" 
                            aria-controls="collapseOne">
                            <span>使用示例</span>
                            <i class="bi bi-chevron-down"></i>
                            </button>
                        </h2>
                        <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
                            <a class="list-group-item list-group-item-action" href="#list-item-3-1">获取API key</a>
                            <a class="list-group-item list-group-item-action" href="#list-item-3-2">下载第三方库</a>
                            <a class="list-group-item list-group-item-action" href="#list-item-3-3">开始使用</a>
                        </div>
                    </div> -->
                    <a class="list-group-item list-group-item-action" href="#list-item-4">相关下载</a>
                </div>
            </div>
            <div class="col-10 mainDocument">
                <div data-bs-spy="scroll" data-bs-target="#list-example" data-bs-smooth-scroll="true"
                    class="scrollspy-example" tabindex="0">
                    <div id="list-item-1">
                    <h3>一、API 服务简介</h3>
                    <div>
                        <p>大数据云服务平台 API 是一套 C# 语言开发的应用编程接口。API 服务提供了基础数据库更新、影像数据库更新等接口，返回结果支持 JSON 格式，满足开发者实现自定义更新数据库的需求。</p>
                        <p>API 服务支持 HTTP 和 HTTPS 协议，并且对所有用户开放。使用本组服务之前，需要<strong>申请Key</strong>。</p>
                        <p>快速了解 API 的功能请前往<a href="#list-item-3">使用示例</a>。</p>
                    </div>
                    </div>

                    
                    <div id="list-item-2">
                    <h3>二、API 接口说明</h3>
                    <h5>HTTP 请求接口</h5>
                    <p>请求接口页面包括基础数据库更新、影像数据库更新，在接口开发过程中后者继承于前者，两者接口方式为POST请求，地址如下：</p>
                    <div class="code-display api">
                        <span class="lang">C#</span>
                        <button class="code-copy"><i class="bi-clipboard"></i></button>
                    </div>
                    <p><a href='' class="swagger"><i class="bi-arrow-right"></i> 了解请求接口页面详情</a></p>
                    
                    <h5>请求参数</h5>
                    <p>基础数据库更新、影像数据库更新接口的请求参数格式为 JSON 对象，两者的请求内容主要包括：<span class="code-excode">sourcecode</span>、
                        <span class="code-excode">apikey</span>、<span class="code-excode">datameta</span>、<span class="code-excode">datamfile</span>。
                        <strong>如无特殊声明，则为接口的共有输入参数</strong>，接口的输入参数和输出数据编码全部统一为 UTF-8。详细参数如下：</p>
                    <div class="row">
                        <div class="col-2"></div>
                        <div class="col-8">
                            <div class="table-responsive">
                                <table class="table table-hover table-sm data">
                                    <thead>
                                    <tr>
                                        <th scope="col">参数</th>
                                        <th scope="col">类型</th>
                                        <th scope="col">必填</th>
                                        <th scope="col">参数说明</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>

                        </div>
                        <div class="col-2"></div>
                    </div>

                    <p><span class="code-excode">datameta</span> 资源元数据为数组对象，详细参数如下：</p>
                    <div class="row">
                        <div class="col-2"></div>
                        <div class="col-8">
                            <div class="table-responsive">
                                <table class="table table-hover table-sm datameta">
                                    <thead>
                                    <tr>
                                        <th scope="col">参数</th>
                                        <th scope="col">类型</th>
                                        <th scope="col">必填</th>
                                        <th scope="col">参数说明</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                        <div class="col-2"></div>
                    </div>

                    <p><span class="code-excode">datamfile</span> 资源数据文件也为数组对象，详细参数如下： </p>
                    <div class="row">
                        <div class="col-2"></div>
                        <div class="col-8">
                            <div class="table-responsive">
                                <table class="table table-hover table-sm datafile">
                                    <thead>
                                    <tr>
                                        <th scope="col">参数</th>
                                        <th scope="col">类型</th>
                                        <th scope="col">必填</th>
                                        <th scope="col">参数说明</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                        <div class="col-2"></div>
                    </div>
                    
                    <p><strong>*** 卫星源传感器详情见「任务中心」——「系统配置」——「特征管理」</strong></p>
                    <div class="row">
                        <div class="col-2"></div>
                        <div class="col-8 text-center">
                            <div>
                                <img src="./assets/img/api/卫星源传感器1.png">
                                <a href="assets/img/api/卫星源传感器1.png" class="img"></a>
                            </div>
                        </div>
                        <div class="col-2"></div>
                    </div>
                    <p><strong>*** 以 ZY3-1 资源三号01星为例，点击「特征值」，即可查看卫星源传感器类型</strong></p>
                    <div class="row">
                        <div class="col-2"></div>
                        <div class="col-8 text-center">
                            <div>
                                <img src="./assets/img/api/卫星源传感器2.png">
                                <a href="assets/img/api/卫星源传感器2.png" class="img"></a>
                            </div>
                        </div>
                        <div class="col-2"></div>
                    </div>
                    </div>



                    <div id="list-item-3">
                    <h3>三、使用示例</h3>
                    <h5>1. 获取API key</h5>
                    <div class="row">
                        <div class="col-1"><i class="bi-chevron-right"></i></div>
                        <div class="col-11">
                            <p>使用元数据 API 开发应用之前需要做一些准备工作。开发者需要登录「任务中心」。</p>
                            <div>
                                <img src="./assets/img/api/步骤1.png">
                                <a href="assets/img/api/步骤1.png" class="img"></a>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-1"><i class="bi-chevron-right"></i></div>
                        <div class="col-11">
                            <p>进入「系统配置」 页面「API 密钥管理」。</p>
                            <div><img src="./assets/img/api/步骤2.png"><a href="assets/img/api/步骤2.png" class="img"></a></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-1"><i class="bi-chevron-right"></i></div>
                        <div class="col-11">
                            <p>为应用添加 Key。添加成功后，可获取到 key 值和元数据 sourcecode。</p>
                            <div><img src="./assets/img/api/步骤3.png"><a href="assets/img/api/步骤3.png" class="img"></a></div>
                        </div>
                    </div>
                    
                    <h5>2. 下载程序包</h5>
                    <p>下载由本网站所提供的程序包 <a href="list-item-6">DTS.Share.Entity</a> ，该程序集是基于 C# .net Standard2.0 
                        框架开发的应用编程接口文件，支持 .net Core 3.0 与 .net Framework 4.6.1 及以上版本框架开发，其封装了 
                        <span class="code-excode">sourcesMeta</span>、<span class="code-excode">ImgDataMeta</span>、
                        <span class="code-excode">ImgDataFile</span></span> 等针对请求参数的实用工具类，可以帮助开发者更快地编写接口工具。</p>
                    <p>在 Visual Studio 中，本地添加已下载的 DTS.Share.Entity 程序集，本示例使用 C# .net 6.0 框架进行开发</p>

                    <h5>3. 开始使用</h5>
                    <p>我们以预先准备好的 csv 格式文件进行演示。csv 中每行表示一景影像，每列表示影像的元数据属性字段；我们需要将每景影像的元数据属性值组合成 HTTP 请求内容，
                        发送至对应的接口地址；等待服务器回应，接收与解析 HTTP 请求返回的数据。
                        csv 内容如下：</p>
                    <div
                        style="height: 280px; width: 80%; background-image: url(./assets/img/api/csv4.png); background-position: top left; 
                        background-size: cover; margin: 25px auto;">
                    </div>
                    <p > 引入 <span class="code-excode">DTS.Share</span> 与 <span class="code-excode">DTS.Share.Entity</span> 的命名空间，
                        调用 <span class="code-excode">sourcesMeta</span> 类，声明一个资源元数据变量 <span class="code-excode">sourceMeta</span>，
                        分别写入获取到的 key 值和 sourcecode 元数据类码。</p>
                    <div class="code-display">
                        <span class="lang">C#</span> 
                        <button class="code-copy"><i class="bi-clipboard"></i></button>
                    </div>
                    <div class="code-area">
                        <pre><code>    <span class="code-type">using</span> DTS.Share.Entity;
    <span class="code-type">using</span> System.Net.Http.Json;
    
    <span class="code-note">//声明sourcesMeta资源元数据变量</span>
    <span class="code-type">var</span> <span class="code-var">sourceMeta</span> = <span class="code-type">new</span> <span class="code-class">SourcesMeta</span>&lt;<span class="code-class">ImgDataMeta</span>, <span class="code-class">ImgDataFile</span>&gt;();
    <span class="code-note">//将获取到的 sourcecode 元数据类码赋值</span>
    <span class="code-var">sourceMeta</span>.sourcecode = <span class="code-string">"S01"</span>;
    <span class="code-note">//将获取到的 key 值赋值</span>
    <span class="code-var">sourceMeta</span>.apikey = <span class="code-string">"9e3d2b54-2a6a-4b67-9a71-1c48e0e1b6d6"</span>;</code></pre>     
                    </div>


                    <p>调用 <span class="code-excode">ImgDataMeta</span> 与 <span class="code-excode">ImgDataFile</span> 类，声明变量影像元数据 
                        <span class="code-excode">dataMeta</span> 与影像数据文件 <span class="code-excode">dataFile</span>，
                        每景影像的属性值需要写入到这两个变量的对应属性当中；再分别添加至 <span class="code-excode">sourcesMeta</span> 的 
                        <span class="code-excode">datameta</span> 与 <span class="code-excode">datamfile</span> 中。
                    </p>
                    <div class="code-display">
                        <span class="lang">C#</span>
                        <button class="code-copy"><i class="bi-clipboard"></i></button>
                    </div>
                    <div class="code-area a1">
                        <pre><code>    <span class="code-type">var</span> <span class="code-var">dataMeta</span> = <span class="code-type">new</span> <span class="code-class">ImgDataMeta</span>();<span class="code-note">//声明ImgDataMeta影像元数据变量，相继录入每行元素的对应字段属性</span>
    <span class="code-var">dataMeta</span>.uid = <span class="code-string">"00d4e3dc-791a-4535-b489-2178670c8a9c";</span><span class="code-note">//元数据唯一标识码</span>
    <span class="code-var">dataMeta</span>.targname = <span class="code-string">"GF1B_PMS_E100.4_N31.3_20230401_L1A1228335017"</span>;<span class="code-note">//目标名称</span>
    <span class="code-var">dataMeta</span>.type = <span class="code-class">Share</span>.Enum_Meta_Type.影像;<span class="code-note">//元数据类型</span>
    <span class="code-var">dataMeta</span>.time = <span class="code-class">DateTime</span>.Parse(<span class="code-string">"2023/4/1"</span>);<span class="code-note">//数据时相</span>
    <span class="code-var">dataMeta</span>.geo = <span class="code-note">//数据矢量范围GeoJSON</span>
        <span class="code-string">"{
            "type":"Polygon",
            "coordinates":
                [[[99.071,28.334],[98.834,27.41],[100.014,27.173],[100.26,28.096],[99.071,28.334]]]
        }";</span>
    <span class="code-var">dataMeta</span>.geoid = <span class="code-string">"00d4e3dc-791a-4535-b489-2178670c8a9c";</span><span class="code-note">//数据矢量唯一标识码</span>
    <span class="code-var">dataMeta</span>.img_cloudperce = 0;<span class="code-note">//影像云量</span>
    <span class="code-var">sourceMeta</span>.datameta.Add(<span class="code-var">dataMeta</span>);<span class="code-note">//将 “dataMeta” 添加至sourcesMeta资源元数据的datameta属性中</span>

    <span class="code-type">var</span> <span class="code-var">dataFile</span> = <span class="code-type">new</span> <span class="code-class">ImgDataFile</span>();<span class="code-note">//声明ImgDataFile影像文件数据变量，相继录入每行元素的对应字段属性</span>
    <span class="code-var">dataFile</span>.uid = DTS.Share.Entity.<span class="code-class">Tools</span>.Md5Encrypt(<span class="code-var">dataMeta</span>.uid + <span class="code-var">dataFile</span>.filename);<span class="code-note">//GUID + 文件名</span>
    <span class="code-var">dataFile</span>.metaid = <span class="code-var">dataMeta</span>.uid;
    <span class="code-var">dataFile</span>.name = <span class="code-string">"GF1B_PMS_E100.4_N31.3_20230401_L1A1228335017-PAN_ortho"</span>;<span class="code-note">//文件名称</span>
    <span class="code-var">dataFile</span>.type = <span class="code-class">Share</span>.Enum_File_Type.原始;<span class="code-note">//文件类型</span>
    <span class="code-var">dataFile</span>.isfile = <span class="code-type">true</span>;<span class="code-note">//是否是文件</span>
    <span class="code-var">dataFile</span>.extension = <span class="code-string">".tar.gz"</span>;<span class="code-note">//文件扩展名</span>
    <span class="code-var">dataFile</span>.shareurl = <span class="code-string">"http://share.gov.cn/img&guid=79865697-b34d-4a0f-b950-e13695a14a4d"</span>;<span class="code-note">//成果发布地址</span>
    <span class="code-var">dataFile</span>.size = <span class="code-type">new</span> <span class="code-class">FileInfo</span>(<span class="code-var">dataFile</span>.fullpath).Length;<span class="code-note">//文件大小</span>
    <span class="code-var">dataFile</span>.sorpath = <span class="code-string">"\\11.11.11.120\nYCX\20230804093215"</span>;<span class="code-note">//文件路径</span>
    <span class="code-var">dataFile</span>.md5= DTS.Share.Entity.<span class="code-class">Tools</span>.GetMD5HashFromFile(<span class="code-var">dataFile</span>.fullpath, <span class="code-type">false</span>);<span class="code-note">//完整性验证码</span>
    <span class="code-var">dataFile</span>.filefeature = <span class="code-string">"GF1B,MUX"</span>;<span class="code-note">//文件特征值，比如："GF1B,MUX"、"GF1B,PAN"</span>
    <span class="code-var">sourceMeta</span>.datafile.Add(<span class="code-var">dataFile</span>);<span class="code-note">//将 “dataFile” 添加至sourcesMeta资源元数据的datamfile属性中</span></code>
                        </pre>
                    </div>
                    <p ><span class="code-excode">sourceMeta</span> 作为 HTTP 请求内容，发送至数据库录入接口地址，即可接收返回的响应结果。</p>
                    <div class="code-display">
                        <span class="lang">C#</span>
                        <button class="code-copy"><i class="bi-clipboard"></i></button>
                    </div>
                    <div class="code-area">
                        <pre><code>    <span class="code-type">HttpClientHandler</span> <span class="code-var">handler</span> = <span class="code-type">new</span> <span class="code-class">HttpClientHandler</span>();
    <span class="code-var">handler</span>.ServerCertificateCustomValidationCallback = (<span class="code-var">t1, t2, t3, t4</span>) => { <span class='code-return'>return</span> <span class="code-var">true</span>; };
    <span class="code-type">var</span> <span class="code-var">httpclinet</span> = <span class="code-type">new</span> <span class="code-class">HttpClient</span>(<span class="code-var">handler</span>);
    <span class="code-note">//将 “sourceMeta” 发送至该地址，以实现数据库录入</span>
    <span class="code-type">var</span> <span class="code-var">response</span> = 
    <span class="code-type">await</span> httpclinet.PostAsJsonAsync(<span class="code-string sendIp"></span>,<span class="code-var">sourceMeta</span>);</code></pre>
                    </div>
                    </div>


                    
                    <div id="list-item-4">
                    <h3>四、相关下载</h3>
                    <div class="container relativeDown">
                        <div class="row ">
                            <div class="col-8">
                                <p>DTS.Share.Entity</p>
                                <p>最后更新时间: 2023年08月17日</p>
                            </div>
                            <div class="col-4">
                                <a href="./assets/software/DTS.Share.Entity.zip" download="DTS.Share.Entity.zip">下载 &nbsp;<i class="bi-cloud-download"></i></a>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <!-- 页脚 -->
    <div class="container">
        <footer class="py-3 my-4">
            <ul class="nav justify-content-center border-bottom pb-3 mb-3">
                <li class="nav-item"><a href="index.html" class="nav-link px-2 text-muted">首页</a></li>
                <li class="nav-item"><a href="task" class="nav-link px-2 text-muted">任务中心</a></li>
                <li class="nav-item"><a href="user" class="nav-link px-2 text-muted">用户中心</a></li>
                <li class="nav-item"><a href="clientDown.html" class="nav-link px-2 text-muted">下载中心</a></li>
                <li class="nav-item"><a href="monitor" class="nav-link px-2 text-muted">监控中心</a></li>
                <li class="nav-item"><a href="#" class="nav-link px-2 text-muted">帮助文档</a></li>
            </ul>
            <p class="text-center text-muted">&copy; 2023 四川测绘地理信息局 大数据中心</p>
        </footer>
    </div>

    <a id="scrollUp" href="#" style="position: fixed; z-index:999; "><i class="bi bi-chevron-compact-up"></i></a>

    <script src="./js/bootstrap/bootstrap.min.js"></script>
    <script src="./js/jQuery/jQeruy.js"></script>
    <script src="./js/axios.min.js"></script>
    <script src="./utils//request.js"></script>
    <script src="./js/myJS/common.js"></script>
    <script src="./js/myJS/API.js"></script>
</body>

</html>